using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using CasaBella.Entities;

namespace CasaBella.Repository.Mapping
{
    public class P_COLCHONESMap : EntityTypeConfiguration<P_COLCHONES>
    {
        public P_COLCHONESMap()
        {
            // Primary Key
            this.HasKey(t => t.PColchonesId);

            // Properties
            this.Property(t => t.PColchonesId)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.Id)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

            // Table & Column Mappings
            this.ToTable("P_COLCHONES");
            this.Property(t => t.PColchonesId).HasColumnName("PColchonesId");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.IdMedida).HasColumnName("IdMedida");
            this.Property(t => t.IdModelo).HasColumnName("IdModelo");

            // Relationships
            this.HasOptional(t => t.MEDIDA_COLCHON)
                .WithMany(t => t.P_COLCHONES)
                .HasForeignKey(d => d.IdMedida);
            this.HasOptional(t => t.MODELO_COLCHON)
                .WithMany(t => t.P_COLCHONES)
                .HasForeignKey(d => d.IdModelo);
            this.HasRequired(t => t.PRODUCTO)
                .WithOptional(t => t.P_COLCHONES)
                .WillCascadeOnDelete(false);
        }
    }
}
